﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Helper
{
    /// <summary>
    /// operate result class
    /// </summary>
    /// <typeparam name="T">operate result return type</typeparam>
    public class Result<T>
    {
        /// <summary>
        /// constructor
        /// </summary>
        protected Result()
        {

        }

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="value">operate return value</param>
        /// <param name="isSuccess">is success</param>
        public Result(T value, bool isSuccess)
            : this(value, isSuccess, string.Empty)
        {

        }

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="value">operate return value</param>
        /// <param name="isSuccess">is success</param>
        /// <param name="errorMsg">error message</param>
        public Result(T value, bool isSuccess, string errorMsg)
        {
            ReturnValue = value;
            IsSuccess = isSuccess;
            ErrorMessage = errorMsg;
        }

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="isSuccess">is success</param>
        /// <param name="errorMsg">error message</param>
        public Result(bool isSuccess, string errorMsg)
        {
            IsSuccess = isSuccess;
            ErrorMessage = errorMsg;
        }





        #region Properties

        private T returnValue;
        /// <summary>
        /// Return Value
        /// </summary>
        public T ReturnValue
        {
            get
            {
                return returnValue;
            }
            set { returnValue = value; }
        }

        private string errorMessage = string.Empty;
        /// <summary>
        /// Error Message
        /// </summary>
        public string ErrorMessage
        {
            get { return errorMessage; }
            set { errorMessage = value; }
        }

        private bool isSuccess = false;
        /// <summary>
        /// if operate success, return true, else return false
        /// </summary>
        public bool IsSuccess
        {
            get { return isSuccess; }
            set { isSuccess = value; }
        }

        #endregion

    }
}
